#include <stdio.h>

int main() {
	int num1[6] = {4, 5, 6, 0, 0, 0};
	int num2[3] = {1, 2, 3};
	int len1 = 3;
	int len2 = 3;

	int p1 = len1 - 1;
	int p2 = len2 - 1;
	int p3 = len1 + len2 - 1;

	while (p1 >= 0 && p2 >= 0) {
		if (num1[p1] > num2[p2]) {
			num1[p3] = num1[p1];
			p3--;
			p1--;
		} else {
			num1[p3] = num2[p2];
			p3--;
			p2--;
		}
	}

	if (p2 >= 0) {
		for (int i = 0; i <= p2; i++) {
			num1[i] = num2[i];
		}
	}

	for (int i = 0; i < len1 + len2; i++) {
		printf("%d ", num1[i]);
	}

	return 0;
}